package com.gk.carshopsys.service;

import com.gk.carshopsys.dao.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class MainServiceImpl implements MainService {
    @Autowired
    EmpDao empDao;
    @Autowired
    CustDao custDao;
    @Autowired
    CarOrderDao carOrderDao;
    @Autowired
    PartOrderDao partOrderDao;
    @Autowired
    AfterOrderDao afterOrderDao;


    @Override
    public Long findEmpCount() {
        return empDao.findempcount();
    }

    @Override
    public Long findCustCount() {
        return custDao.findcustcount();
    }

    @Override
    public Long findOrderCount() {

        return carOrderDao.findOrderMouthCount()
                +partOrderDao.findOrderMouthCount()
                +afterOrderDao.findOrderMouthCount();
    }

    @Override
    public Long findincomeCount() {
        long count=0;
        if (carOrderDao.findOrderMouthCountIncome()!=null){
            count=count+carOrderDao.findOrderMouthCountIncome();
        }
        if (partOrderDao.findOrderMouthCountIncome()!=null){
            count=count+carOrderDao.findOrderMouthCountIncome();
        }
        if (afterOrderDao.findOrderMouthCountIncome()!=null){
            count=count+carOrderDao.findOrderMouthCountIncome();
        }

        return count;
    }

    @Override
    public List<Map> findAddressNum() {
        return custDao.findAddressNum();
    }

    @Override
    public List<Map> findCarSales() {
        return carOrderDao.findCarSales();
    }
}
